package o;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.huawei.appgallery.assistantdock.base.externalaction.openviewaction.RemoteBuoyAction;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import com.huawei.appmarket.service.activitydispatcher.OpenGateway;
import com.huawei.appmarket.service.activitydispatcher.OpenGateway$c;
import com.huawei.appmarket.service.externalapi.actions.ExtPublicAction;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import o.dys.a;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public abstract class dyw {
    protected Uri ˊ;
    protected dyr ˎ;
    protected a ˏ;

    public abstract void ॱ();

    public dyw(@NonNull dyr o_dyr, @NonNull a aVar, @NonNull Uri uri) {
        this.ˎ = o_dyr;
        this.ˏ = aVar;
        this.ˊ = uri;
    }

    protected void ˎ(String str, String str2) {
        Intent intent = this.ˏ.getIntent();
        if (intent != null) {
            intent.putExtra("thirdId", str2);
            intent.putExtra("openStr", str);
            new ExtPublicAction(this.ˏ).onAction();
            return;
        }
        Logger.ˋ("ViewActionJumper", "showMainLayout getIntent error");
    }

    protected void ˊ(String str, String str2, String str3, boolean z) {
        if (TextUtils.isEmpty(str)) {
            Logger.e("ViewActionJumper", "can not find activityName.");
        } else {
            JSONArray jSONArray = null;
            if (!TextUtils.isEmpty(str2)) {
                try {
                    jSONArray = new JSONObject(str2).getJSONArray(RemoteBuoyAction.REMOTE_BUOY_PARAM);
                } catch (JSONException e) {
                    Logger.e("ViewActionJumper", "can not get params:" + e.toString());
                    this.ˏ.finish();
                    return;
                }
            }
            if (z) {
                epr.ˎ().ˎ(str3);
            }
            Logger.ˎ("ViewActionJumper", "open :" + str);
            OpenGateway$c ˎ = OpenGateway.ˎ(str, jSONArray, true);
            if (ˎ != null) {
                if (ˎ.ˎ() != null) {
                    this.ˏ.ˎ(ˎ.ˎ(), 0);
                } else if (ˎ.ˏ() != null) {
                    this.ˏ.startActivity(ˎ.ˏ());
                } else if (ˎ.ˊ() != null) {
                    this.ˏ.ˏ(ˎ.ˊ().ˋ, ˎ.ˊ().ˏ);
                } else {
                    Logger.e("ViewActionJumper", "can not start target activity.Go MainActivity");
                }
            }
        }
        this.ˎ.dailyReport(str3);
        this.ˏ.finish();
    }

    protected void ˊ() {
        this.ˏ.ˎ(new cjm("main.activity", null), 0);
        this.ˏ.finish();
    }

    protected void ˏ(String str, String str2) {
        cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
        Request request = new Request();
        request.ˋ(str + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + str2);
        request.ˎ(true);
        appDetailActivityProtocol.ˏ(request);
        this.ˏ.ˎ(new cjm("appdetail.activity", appDetailActivityProtocol), 0);
        this.ˏ.finish();
    }

    protected void ॱ(Uri uri) {
        String scheme = uri.getScheme();
        String host = uri.getHost();
        if (scheme.isEmpty() || host.isEmpty()) {
            this.ˏ.finish();
            return;
        }
        try {
            emz.ॱ((Activity) this.ˏ, "internal_webview", URLDecoder.decode(uri.toString(), "UTF-8"));
            this.ˏ.finish();
        } catch (UnsupportedEncodingException e) {
            Logger.ˋ("ViewActionJumper", "error to decode h5url");
            this.ˏ.finish();
        }
    }
}
